package com.java2404.micro.consumer.client;

import com.java2404.micro.common.entity.Order;
import com.java2404.micro.common.resp.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = "cloud-gateway")  // 网关服务的名称称
public interface GatewayClient {

    // 扣减库存接口 TODO
    @GetMapping("/storage/sale")  // 网关的商品接口路径
    Result<Boolean> deductStock(@RequestParam("gid") Integer gid,@RequestParam("amount") Integer amount); // 扣减商品库存

    // 添加订单接口
    @PostMapping("/order/addOrder")  // 网关的订单创建接口路径
    Result addOrder(@RequestBody Order order);  // 创建订单

    // 查询订单接口  TODO
    @GetMapping("/order/getOrder")
    Order getOrder(@RequestParam("orderId") Integer orderId);

    // 更新订单接口  TODO
    @PostMapping("/order/updateOrder")
    Result updateOrder(@RequestBody Order order);

    // 检查库存是否足够 TODO
    @GetMapping("/storage/checkStock")
    Result<Boolean> checkStock(@RequestParam("gid") Integer gid, @RequestParam("amount") Integer amount);

    // 查询库存商品名称接口 TODO
    @GetMapping("/storage/name")
    Result<String> getGoodsName(@RequestParam("gid") Integer gid);

}
